% [val,text,raw] = xlsread('VNIBOR.xlsx');
% 
% vnibor = val(:,2);
% 
% retVNIBOR = vnibor(2:end)-vnibor(1:end-1);
% ret2VNIBOR = retVNIBOR(2:end) - retVNIBOR(1:end-1);

%% interpolate
% % [val,text,raw] = xlsread('Book1.xlsx',5);
% 
% m2 = val(1: end);
% % d = datenum(text(2:end,1),'mm/dd/yyyy');
% 
% index = ~isnan(m2);
% m2adj = m2(index);
% d2 = d(index);
% 
% figure
% vq1 = interp1(d2,m2adj,d,'spline');
% plot(d2,m2adj,'o',d,vq1,'+');
% title('(Default) Linear Interpolation');

%% stepwise regression
% [val,text,raw] = xlsread('Book1.xlsx',8);
N = 120;
[val,text,raw] = xlsread('Book1.xlsx',9);
vnibor = val(1:N,1);
iv = val(1:N,2:end);
% [b,se,pval,inmodel,stats,nextstep,history] = stepwisefit(iv, vnibor)
% stepwise(iv, vnibor)
mdl1 = LinearModel.stepwise(iv,vnibor,'linear', 'Criterion','AIC','VarNames',{'CPI','TD','USD','CreditCB','vnibor1m'},'Penter',0.01,'Premove',0.1)

figure(1)

plot(vnibor);
hold on;
plot(mdl1.Fitted,'r')



